var User;
var OpenId;
var userSign ="";

function setOpenId(openid){
    this.OpenId=openid;
}

function getOpenId(){
    return this.OpenId;
}

var Param = {
    Version:"2.1.3",
    Platform:"WeApp",
    AppSecret:"86c42d9dc49e31ded1936a71854c0fdfb67b8505"
}

function toDecimal2(x) {
    var f = parseFloat(x);
    if (isNaN(f)) {
        return false;
    }
    var f = Math.round(x * 100) / 100;
    var s = f.toString();
    var rs = s.indexOf('.');
    if (rs < 0) {
        rs = s.length;
        s += '.';
    }
    while (s.length <= rs + 2) {
        s += '0';
    }
    return s;
}

function setUserSign(userSign){
    this.userSign = userSign;
}

function getUserSign(){
    return this.userSign;
}

function getUser() {
    return this.User;
}

function setUser(User){
    this.User = User;
}

function setCity(cityId, cityName){
    var city = {
        cityId:cityId,
        cityName:cityName
    };
    wx.setStorageSync('city', city);
}

function getCityId(){
    return wx.getStorageSync('city').cityId;
}

function getCityName(){
    return  wx.getStorageSync('city').cityName;
}

function getVersion(){
    return Param.Version;
}

function getPlatform(){
    return Param.Platform;
}

function getAppSecret(){
    return Param.AppSecret;
}





function setUserStorage(User){
    wx.setStorageSync('User', User);
}

function getUserStorage(){
    return wx.getStorageSync('User');
}

function clearUserStorage(){
    wx.clearStorageSync('User');
}


module.exports = {
    getUser: getUser,
    setUser:setUser,
    setUserStorage:setUserStorage,
    getUserStorage:getUserStorage,
    clearUserStorage:clearUserStorage,
    getVersion:getVersion,
    getPlatform:getPlatform,
    getAppSecret:getAppSecret,
    setCity:setCity,
    getCityId: getCityId,
    getCityName: getCityName,
    toDecimal2: toDecimal2,
    setOpenId:setOpenId,
    getOpenId:getOpenId,
    setUserSign:setUserSign,
    getUserSign:getUserSign
}